Missing function - olePut with AutoArgs?

I am using OLE Automation to get and set data within another application. One of the properties of the OleAutoObj that I am dealing with is effectively an array of data. I can 'get' data from this array by using oleGet with AutoArgs, however I am unable to 'set' the same piece of data, as there is no olePut function for which I can supply AutoArgs as an argument. The section of code for the 'get' is as follows:
 

OleAutoObj nodeAutoObj
    string nodeConf = ""
 
    OleAutoArgs autoArgs = create
    clear autoArgs
 
    put(autoArgs, "confidence")
 
    string err = oleGet(nodeAutoObj, "StatusField", autoArgs, nodeConf)
 
    if(!null err)
    {
        errorBox "ERROR getting nodeConf: " err
    }
 
    if(!null nodeConf)
    {
        infoBox "nodeConf: " nodeConf
    }

 


In order to 'set' this piece of data, the code I effectively need would be something like the following:

 

 

 

clear autoArgs
 
    put(autoArgs, "confidence")
    err = olePut(nodeAutoObj, "StatusField", autoArgs, "Low")
 
    if(!null err)
    {
        errorBox "ERROR setting nodeConf: " err
    }



But unfortunately there is no olePut function, that takes OleAutoArgs as an argument.

Any ideas of how I can overcome this appreciated. Note: 'StatusField' is a property of an OleAutoObj, but not an OleAutoObj in itself, and therefore cannot be got, modified, and put back.



 

 


SystemAdmin - Tue May 10 08:20:12 EDT 2011

Re: Missing function - olePut with AutoArgs?
Mathias Mamsch - Tue May 10 09:30:58 EDT 2011

Hmm what you are describing sound not like a normal "array" ... DXL does not support COM arrays, but that does not seem to be your problem... COM objects like a VB collection have "default" methods. This means when you call:

MyCollection(3) = 4
x = MyCollection(6)

 


what COM is doing for you is:

 

 

MyCollection.Items(3).Value = 4
x = MyCollection.Items(6).Value



Therefore it might be possible that the property you are calling is just a default property, but there is another Method, that will yield an OleAutoObj for the item for which you want to set the property.



 

 

 

clear autoArgs 
OleAutoObj objField
put(autoArgs, "StatusField")
oleMethod(nodeAutoObj, "Fields", autoArgs, objField)
olePut(objField, "confidence", "Low")



But its hard to tell, without knowing the concreate OLE object. What you always can do, is inspect the OLE interface using some tool see here for example to find out, if there is such a property.

Hope this helps, regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: Missing function - olePut with AutoArgs?
SystemAdmin - Tue May 10 10:20:01 EDT 2011

Mathias Mamsch - Tue May 10 09:30:58 EDT 2011

Hmm what you are describing sound not like a normal "array" ... DXL does not support COM arrays, but that does not seem to be your problem... COM objects like a VB collection have "default" methods. This means when you call:

MyCollection(3) = 4
x = MyCollection(6)

 


what COM is doing for you is:

 

 

MyCollection.Items(3).Value = 4
x = MyCollection.Items(6).Value



Therefore it might be possible that the property you are calling is just a default property, but there is another Method, that will yield an OleAutoObj for the item for which you want to set the property.



 

 

 

clear autoArgs 
OleAutoObj objField
put(autoArgs, "StatusField")
oleMethod(nodeAutoObj, "Fields", autoArgs, objField)
olePut(objField, "confidence", "Low")



But its hard to tell, without knowing the concreate OLE object. What you always can do, is inspect the OLE interface using some tool see here for example to find out, if there is such a property.

Hope this helps, regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Thanks for your reply Mathias, we have been using the OLE/COM viewer, and can see that 'StatusField' is a property. I also know that StatusField contains an array of other data, which is referenced by a key. In the example I gave the array element I am trying to set is referenced by the string "confidence". The code you gave me generates an error because it's not happy with the OLE Argument name supplied to OLEMethod (i.e. "Fields").

My colleague, had a similar problem setting some data in MS Word 2003, where he was trying to specify a 'WdCompatibility' element value in the Compatibility property:

Application.Document.Compatibility(WdCompatibility) = false

Compatibility is a Property not a Method
WdCompatibility is an integer

This is essentially the same problem, however might easier to investigate, as most people have Word.

Re: Missing function - olePut with AutoArgs?
Mathias Mamsch - Tue May 10 13:39:48 EDT 2011

SystemAdmin - Tue May 10 10:20:01 EDT 2011
Thanks for your reply Mathias, we have been using the OLE/COM viewer, and can see that 'StatusField' is a property. I also know that StatusField contains an array of other data, which is referenced by a key. In the example I gave the array element I am trying to set is referenced by the string "confidence". The code you gave me generates an error because it's not happy with the OLE Argument name supplied to OLEMethod (i.e. "Fields").

My colleague, had a similar problem setting some data in MS Word 2003, where he was trying to specify a 'WdCompatibility' element value in the Compatibility property:

Application.Document.Compatibility(WdCompatibility) = false

Compatibility is a Property not a Method
WdCompatibility is an integer

This is essentially the same problem, however might easier to investigate, as most people have Word.

Yes ... you are right ... DXL does not seem to support setting properties with parameters. Weird. The only chance I am seeing for you is to create a custom COM object, that will inherit the original interface and provide a setter method for the problematic property... Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Missing function - olePut with AutoArgs?
SystemAdmin - Thu May 12 11:19:22 EDT 2011

Mathias Mamsch - Tue May 10 13:39:48 EDT 2011
Yes ... you are right ... DXL does not seem to support setting properties with parameters. Weird. The only chance I am seeing for you is to create a custom COM object, that will inherit the original interface and provide a setter method for the problematic property... Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Thanks for looking in to this Mathias, I shall raise it with IBM.